{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <fieldset id="searchFieldset_currentTableRenderId" class="table-search-fieldset">
                        <legend>条件搜索</legend>
                        <form class="layui-form layui-form-pane form-search">
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">所属小区</label>
                                <div class="layui-input-inline">
                                    <select name="xiaoquid" lay-search>
                                        <option value="">无</option>
                                        {foreach $xiaoqu as $xiaoqus}
                                        <option value="{$xiaoqus.id}" {if !empty(input('get.xiaoquid')) &&
                                            input('get.xiaoquid')==$xiaoqus.id}selected{/if}>
                                            {$xiaoqus.name}({$xiaoqus.address})|{$xiaoqus.agent_name}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">商家状态</label>
                                <div class="layui-input-inline">
                                    <select name="status">
                                        <option value="">商家状态</option>
                                        <option value="1" {if !empty(input('get.status')) &&
                                            input('get.status')==1}selected{/if}>正常</option>
                                        <option value="2" {if !empty(input('get.status')) &&
                                            input('get.status')==2}selected{/if}>下线</option>
                                        <option value="3" {if !empty(input('get.status')) &&
                                            input('get.status')==3}selected{/if}>删除</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">店铺名称|账号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="title" placeholder="商家名称|账号" value="{:input('get.title')}"
                                        autocomplete="off" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-form-item layui-inline">
                                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="sreach">搜索</button>
                            </div>
                        </form>
                    </fieldset>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn layui-bg-cyan layui-btn-sm" onclick="open_add('添加','shoplist_edit')"><i
                            class="layui-icon">&#xe654;</i>添加</button>&nbsp;
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>
                                    <div class="layui-table-cell">ID</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">所属合伙人</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">商家类型</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">上架项目</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">服务小区</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">商家</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">钱包余额</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">入账收益</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">商家账号</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">系统备注</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">服务时间</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">状态</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">操作</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>
                                    <div class="layui-table-cell">{$v.id|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.agent_name|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">
                                        {if $v.type == 1}
                                        <a title="上门服务" href="javascript:;"
                                            class="layui-btn layui-btn-normal layui-btn-sm">
                                            上门服务
                                        </a>
                                        {else}
                                        <a title="本地商家" href="javascript:;" class="layui-btn layui-btn-sm">
                                            本地商家
                                        </a>
                                        {/if}
                                        {if !empty($v.sonstype_name)}
                                        [{$v.sonstype_name}]
                                        {/if}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">
                                        <a title="项目列表" onclick="open_add('项目列表','/shop/goodslist?businessid={$v.id}')"
                                            href="javascript:;" class="layui-btn layui-btn-normal layui-btn-sm">
                                            {$v.goods}个项目
                                        </a>
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">
                                        <a title="服务小区"
                                            onclick="open_add('服务小区','/shop/businesscommu?businessid={$v.id}')"
                                            href="javascript:;" class="layui-btn layui-btn-normal layui-btn-sm">
                                            服务小区
                                        </a>
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.title|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.money|default='0'}元</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.income|default='0'}元</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.account|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.remark|default='无'}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.fwtime|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{if !empty($v.status) && $v.status ==
                                        1}正常{elseif $v.status == 2}下线{else}冻结{/if}</div>
                                </td>
                                <td class="td-manage">
                                    <div class="layui-table-cell">
                                        {if $v.type == 1}
                                        <a title="导入产品" onclick="open_add('导入产品','/system/goodslist?business={$v.id}')"
                                            href="javascript:;" class="layui-btn layui-btn-normal layui-btn-sm">
                                            导入产品
                                        </a>
                                        {/if}
                                        <a title="服务客户" onclick="open_add('商家客户','/shop/users?business={$v.id}')"
                                            href="javascript:;" class="layui-btn layui-btn-normal layui-btn-sm">
                                            服务客户
                                        </a>
                                        <a title="收益记录" onclick="open_add('收益记录','/shop/businesslog?id={$v.id}')"
                                            href="javascript:;" class="layui-btn layui-btn-normal layui-btn-sm">
                                            收益记录
                                        </a>
                                        <a title="操作" onclick="open_add('操作','/shop/shoplist_edit?id={$v.id}')"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            操作
                                        </a>
                                    </div>
                                </td>

                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
{include file="public/footer"}
<script>
    function money_edit(title, url, id) {
        layer.prompt({
            formType: 0,
            value: 0,
            title: title,
        }, function (value, index, elem) {
            $.ajax({
                type: 'post',
                url: url,
                data: { id: id, money: value },
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                            layer.close(index);
                            // 获得frame索引
                            location.reload();
                        });
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;

        });
    }
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;
        //监听省份选择
        form.on('select(province)', function (data) {
            if (!data.value) {
                $('select[name="city"]').html('');
                $('select[name="area"]').html('');
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 2 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择城市</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.area_code;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="city"]').html(str);
                        $('select[name="area"]').html('');
                        $('select[name="street"]').html('');
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
        //监听城市选择
        form.on('select(city)', function (data) {
            if (!data.value) {
                $('select[name="area"]').html('');
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 3 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择区域</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.area_code;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="area"]').html(str);
                        $('select[name="street"]').html('');
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
        //监听区域选择
        form.on('select(area)', function (data) {
            if (!data.value) {
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 4 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择街道</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.id;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="street"]').html(str);
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
        //监听分类 
        form.on('select(platclassid)', function (data) {
            if (!data.value) {
                $('select[name="sonsid"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getsons',
                data: { classid: data.value },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择分类</option>';
                        $.each(res.data, function (i, obj) {
                            console.log(obj);
                            str += '<option value="' + obj.id;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="sonsid"]').html(str);
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
    });
</script>
<script>
    layer.photos({
        photos: '#layer-photos'
        , anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
    });
</script>
{include file="public/footer"}